package com.example.service.impl;

import com.example.dao.AdminDao;
import com.example.entity.Admin;
import com.example.entity.PageInfo;
import com.example.entity.Student;
import com.example.service.AdminService;
import com.example.util.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 管理员对象服务层接口实现类
 * @author 李平
 * @Date 2022-5-2
 */
@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminDao adminDao;

    /**
     * 用户-管理员登录业务
     * @param name
     * @param password
     * @return Admin
     */
    @Override
    public Admin getAdminByPAndP(String name, String password) {
        return adminDao.getAdminByPAndP(name, MD5Util.md5(password));
    }

    /**
     * 通过name查询管理员信息业务
     * @param name
     * @return Admin
     */
    @Override
    public Admin getAdminByPhone(String name) {
        return adminDao.getAdminByPhone(name);
    }

    @Override
    public List<Student> getAllStudent(PageInfo info){return  adminDao.getAllStudent(info);}

    @Override
    public int getTotal() {
        return adminDao.getCount();
    }

    @Override
    public Boolean deleteStudent(String id) {
        return adminDao.deleteStudent(id);
    }

    @Override
    public int getTotal(String search) {
        return adminDao.getCount(search);
    }


}
